package cn.bb.shop.api.Impl;

import cn.bb.shop.api.IShopOrder;

import java.io.IOException;
import java.net.Socket;

public class ShopOrder implements IShopOrder {
    @Override
    public String getOrder(String OdrerId) throws IOException {
        Socket socket =  new Socket("127.0.0.1",8080);
        String pageName = "cn.bb.shop.api.Impl/r/n";
        String className = "ShopOrder/r/n";
        String methodName = "getOrder/r/n";
        String argsName = "NO:007/r/n";
        //输出流
        socket.getOutputStream().write(pageName.getBytes());
        socket.getOutputStream().write(className.getBytes());
        socket.getOutputStream().write(methodName.getBytes());
        socket.getOutputStream().write(argsName.getBytes());


        byte[] b= new byte[1];
        String response = "";
        while (socket.getInputStream().read(b) != -1){
            response = response+new String(b);
        }
        System.out.println("接收服务端返回的数据是："+response);
        socket.shutdownOutput();//手动关闭
        socket.close();
        return response;
    }
}
